Change user password test and fix

jamesperet 9 years ago
parent
commit
c8ab59e1da

+ 1 - 1
app/controllers/application_controller.rb

@@ -12,7 +12,7 @@ class ApplicationController < ActionController::Base
12 12
   before_filter :configure_permitted_parameters, if: :devise_controller?
13 13
   
14 14
   def configure_permitted_parameters
15
-    devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :last_name, :email, :current_password, :avatar) }
15
+    devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :last_name, :email, :current_password, :avatar, :password, :password_confirmation) }
16 16
     devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :email, :password) }
17 17
   end
18 18
     

+ 4 - 4
app/views/devise/registrations/edit.html.erb

@@ -23,17 +23,17 @@
23 23
 	    					</span>
24 24
 	    			    </div>
25 25
 				    
26
-				    <%= f.text_field :first_name, label: (t 'registration.first_name'), required:true, autofocus: true, class: 'span4' %>
27
-				    <%= f.text_field :last_name, label: (t 'registration.last_name'), required:true, class: 'span4' %>
26
+				    <%= f.text_field :first_name, label: (t 'registration.first_name'), required: true, autofocus: true, class: 'span4' %>
27
+				    <%= f.text_field :last_name, label: (t 'registration.last_name'), required: false, class: 'span4' %>
28 28
 				    <%= f.email_field :email, required: true, class: 'span4' %>
29 29
 				    </div>
30 30
 				    <hr>
31 31
 				    <div class="form-inputs">
32 32
 			    		    <%= f.form_group :title, class: "pull-left", style: 'margin-left: 0px; width: 30%;' do %>
33
-			    		        <%= f.password_field :password, label: (t 'registration.password'), required: true, class: 'input-block-level' %>
33
+			    		        <%= f.password_field :password, label: (t 'registration.password'), required: false, class: 'input-block-level' %>
34 34
 			    		    <% end %>
35 35
 			    		    <%= f.form_group :slug, class: "pull-left", style: 'margin-left: 27px; width: 30%;' do %>
36
-			    		        <%= f.password_field :password_confirmation, label: (t 'registration.password_confirmation'), required: true, class: 'input-block-level' %>
36
+			    		        <%= f.password_field :password_confirmation, label: (t 'registration.password_confirmation'), required: false, class: 'input-block-level' %>
37 37
 			    		    <% end %>
38 38
 			    		    <%= f.form_group :slug, class: "pull-left", style: 'margin-left: 27px; width: 30%;' do %>
39 39
 			    		        <%= f.password_field :current_password, label: (t 'registration.current_password'), required: true, class: 'input-block-level' %>

+ 33 - 3
features/user_account.feature

@@ -38,8 +38,7 @@ Feature: User Account
38 38
 		And I should see "Monty Cantsin"
39 39
 		And I should see "Logout"
40 40
 		And "monty_cantsin@canada.com" should receive an email with subject "Welcome to Rails Website Template"
41
-	
42
-	@focus	
41
+			
43 42
 	Scenario: User forgets password
44 43
 		Given the user "Monty" "Cantsin" with email "monty_cantsin@canada.com" and password "12345678" exists
45 44
 		And I am not logged in
@@ -58,4 +57,35 @@ Feature: User Account
58 57
 		Then I should see "Your password was changed successfully. You are now signed in."
59 58
 		And I should see "Monty Cantsin"
60 59
 		And I should see "Logout"
61
-		
60
+		
61
+	Scenario: Change user name and email
62
+		Given the user "Monty" "Cantsin" with email "monty_cantsin@canada.com" and password "12345678" exists
63
+		And I go to the login page
64
+		And I log in with the email "monty_cantsin@canada.com" and password "12345678"
65
+		And I go to the homepage
66
+		When I click in the link "Account"
67
+		Then I should see "Edit Profile"
68
+		And I fill in "First Name" with "Donald"
69
+		And I fill in "Last Name" with "Duck"
70
+		And I fill in "Email" with "donald_duck@looneytunes.com"
71
+		And I fill in "Current Password" with "12345678"
72
+		And I click in the button "Update"
73
+		Then I should see "You updated your account successfully"
74
+		Then I should see "Donald Duck"
75
+	
76
+	@focus	
77
+	Scenario: Change user password
78
+		Given the user "Monty" "Cantsin" with email "monty_cantsin@canada.com" and password "12345678" exists
79
+		And I go to the login page
80
+		And I log in with the email "monty_cantsin@canada.com" and password "12345678"
81
+		And I go to the homepage
82
+		When I click in the link "Account"
83
+		And I fill in "Password" with "87654321"
84
+		And I fill in "Password Confirmation" with "87654321"
85
+		And I fill in "Current Password" with "12345678"
86
+		And I click in the button "Update"
87
+		Then I should see "You updated your account successfully"
88
+		And I click in the link "Logout"
89
+		And I go to the login page
90
+		And I log in with the email "monty_cantsin@canada.com" and password "87654321"
91
+		Then I should see "Signed in successfully"